package demo2;

//空间优化版

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int aim = scanner.nextInt();
        int[] arr = new int[n+1];
        for(int i = 1; i<=n; i++) {
            arr[i] = scanner.nextInt();
        }
        int[] dp = new int[aim+1];
        for (int j = 0; j <= aim; j++) {
            dp[j] = Integer.MAX_VALUE - 10001;
        }
        dp[0] =0;
        for(int i = 1; i<=n; i++) {
            for(int j = arr[i]; j<=aim; j++) {
                dp[j] = Math.min(dp[j], dp[j-arr[i]] + 1);
                //System.out.print(dp[i][j]+" ");
            }
            //System.out.println();
        }
        if(dp[aim] == Integer.MAX_VALUE-10001) {
            System.out.println(-1);
        }else {
            System.out.println(dp[aim]);
        }
    }
}

/*
dp[i][j]: 在前i种货币里能兑换出面值为j的最少货币数

不选第i种: dp[i][j] = dp[i-1][j]
选第i种
1张: dp[i][j] = dp[i-1][j-arr[i]] + 1;
2张: dp[i][j] = dp[i-1][j-2*arr[i]] + 2;
3张: dp[i][j] = dp[i-1][j-3*arr[i]] + 3;
...
dp[i-1][j] = dp[i-2][[j-arr[i]] + 1;
 */
